//
//  PhotoTableViewController.m
//  QingSongYiKe
//
//  Created by lanou3g on 16/3/21.
//  Copyright © 2016年 wanshuai. All rights reserved.
//

#import "PhotoTableViewController.h"
#import "SegmentTableViewController.h"
#import "PassValueForPhotoTitle.h"
@interface PhotoTableViewController ()
@property(nonatomic,strong)UISegmentedControl *photoSegment;
@end

@implementation PhotoTableViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
   
   
    
    
    SegmentTableViewController *segVC = [SegmentTableViewController new];
    [self.navigationController pushViewController:segVC animated:YES];

    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255/256.0 green:0/256.0 blue:0/256.0 alpha:1];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:20],NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    
    
    
    [self FirstView];
    [self initLayout];
    
}

- (void)FirstView
{
    
    SegmentTableViewController *segVC = [SegmentTableViewController new];
    PassValueForPhotoTitle *passValue = [PassValueForPhotoTitle shareValue];
    passValue.title = [self.photoSegment titleForSegmentAtIndex:0];
    [self.navigationController pushViewController:segVC animated:YES];
    

}
- (void)initLayout
{
    NSArray *segmentArray = @[@"美女",@"GIF",@"图片"];
    self.photoSegment = [[UISegmentedControl alloc] initWithItems:segmentArray];
    self.photoSegment.frame = CGRectMake(self.view.frame.size.width/5.5, self.view.frame.size.height /25, 300, 34);
    
    self.photoSegment.backgroundColor = [UIColor redColor];
    //设置字体大小以及颜色
    [self.photoSegment setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:15],NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal];
    self.photoSegment.layer.masksToBounds = YES;
    //弯度
    self.photoSegment.layer.cornerRadius = 8;
    //边框的宽度
    self.photoSegment.layer.borderWidth = 2;
    //边框颜色
    self.photoSegment.layer.borderColor = [UIColor blackColor].CGColor;
    //设置segment的样式
    self.photoSegment.segmentedControlStyle = UISegmentedControlStyleBar;
    //点击后的颜色
    self.photoSegment.tintColor = [UIColor whiteColor];
    [self.navigationController.view addSubview:self.photoSegment];
    [self.photoSegment addTarget:self action:@selector(segmentFirstClick) forControlEvents:UIControlEventValueChanged];
    //启动后默认选择的下标
    self.photoSegment.selectedSegmentIndex = 0;
    
    
    
}

- (void)segmentFirstClick
{
    
    
    PassValueForPhotoTitle *passValue = [PassValueForPhotoTitle shareValue];
    NSInteger index = self.photoSegment.selectedSegmentIndex;
    if (index == 0) {
        
        
        SegmentTableViewController *segVC = [SegmentTableViewController new];
         passValue.title = [self.photoSegment titleForSegmentAtIndex:0];
        [self.navigationController pushViewController:segVC animated:YES];
        
        
    }else if (index == 1){
        
        
        
        SegmentTableViewController *segVC = [SegmentTableViewController new];
        passValue.title = [self.photoSegment titleForSegmentAtIndex:1];
        [self.navigationController pushViewController:segVC animated:YES];
        
        
    }else{
        
        
        
        SegmentTableViewController *segVC = [SegmentTableViewController new];
         passValue.title = [self.photoSegment titleForSegmentAtIndex:2];
        [self.navigationController pushViewController:segVC animated:YES];
        
        
    }
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {




    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {



    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
